<?php

namespace App\Models;

/**
 * App\Models\AdminRole
 *
 * @property int $id
 * @property string $name 角色名称
 * @property int $is_super 是否超级管理员：1是 0否
 * @property string $desc 描述
 * @property array $menu_ids 权限ID集合，存储结构为json数据，内容为admin_menus表ID集合
 * @property array $menu_texts 权限ID集合，存储结构为json数据，内容为admin_menus表ID集合
 * @property int $is_delete 是否删除：1是 0否
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel paramsQuery($fields, $params = [])
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole query()
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereDesc($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereIds($ids = [])
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereIsDelete($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereIsSuper($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereMenuIds($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereMenuTexts($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRole whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class AdminRole extends BaseModel
{
    protected $table = 'admin_roles';

    protected $casts = [
        'menu_ids'   => 'array',
        'menu_texts' => 'array',
    ];

    public function scopeBgBaseQuery($query, $params = [])
    {
        $query->paramsQuery(['name'], $params);
    }

    public function admin()
    {
        return $this->hasOne(Admin::class, 'role_id', 'id');
    }
}
